﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using RomaClient.RomaReference;
using RomaClient.Models;

namespace RomaClient.Controllers
{
    public class PrivateMessageController : Controller
    {
        private RoMaWSClient proxy = new RoMaWSClient();

        //
        // GET: /PrivateMessage/

        public ActionResult Index()
        {
            userUI user = (userUI)Session["user"];
            PMStartModel model = new PMStartModel();
            model.receviedMessages = proxy.getReceivedPrivateMessages(user.id);
            model.sentMessages = proxy.getSentPrivateMessages(user.id);

            return View(model);
        }

        [HttpGet]
        public ActionResult Write()
        {
            return View();
        }

        [HttpPost]
        public ActionResult Write(string message, string receiver, string title)
        {
            userUI user = (userUI)Session["user"];
            proxy.sendPrivateMessage(receiver, title, message, user.id);
            return RedirectToAction("Index");
        }


        public ActionResult Read()
        {
            
            return View();
        }



    }
}
